Preparations for menu system
More refactoring and fixing