Refactoring and sense checking