fixed thread exit and some scheduler memory leaks. to do: scheduler audit