refactoring and clearing cruft