Some refactoring in map library.