Refractor the mapgen code in a way that makes more sense