Some refactoring and add base map system.