Terrain generator

Added a bunch of optimizations and restructuring to the map generation. Caves are hard, so that will be a problem solved another day.
1) Is this thread safe? I thought generators could be called from multiple threads concurrently (although I can't remember exactly).