Improved thread safety of terrain loading vs rendering in different
threads. Still some issue with OpenGL loading from other thread, since
terrain patches do not use the resource manager (which is TS)
switched terrain to bg_thread and made some more global/static
variables. Added some kind of deadlock upon exit. Probably due to dirty
globals...