Refactured some code.