Refactoring and adding features