Enable updating maps. Some clean and refactoring. Need test.