cleanups and refactoring for main
introducing map popup menu