Refactor and clean up.