More minor cleanup.
Made core classes threadsafe.