Refactoring structure and code