Moved critical section and resource update functions to dlls/kernel. Started moving some of the thread functions too.