Various cleans and optimizes