map fix and code cleanup