Partially refactored code.