Refactor Map handling