Final refactoring and layout