Refactoring and stuff