Final set of the refactored code.