Refactoring and layout improvements