Refactoring: DONE. Welcome, working version!