couple small optimizations in mapgen code