Clean up map generation algorithm code