Refactor some code.