Refactoring and additions