Initial refactoring of navigation and logic