Multiple deadlock and crash fixes.
Fixed some issues with MapGenerator.