Refactors some code.