fix some errors and clean up