clean up and error fixes