Refactored out the terrain generator

And some other things. Making it pluggable but will have ok defaults.