Code and design refactoring