Move maps to util, and refactor more