Cleans and refactors.