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.
I'd rather not . import this. It makes it more confusing where symbols are coming from, and there doesn't seem to be a huge benefit in this case.