clean up of code and some comments