Refactoring and code style