Several fixes and improvements to the mapgen