clean up
some more clean up and optimization