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.
Also, the map type should really just be a command-line argument, but this diff is big enough already.