Refactoring, layout fixes