bug fixes and clean up for map