little more refactoring before changing map.events from a 2D array to a 1D array (i think)