clean up and fix errors