code cleanup
Lots of code cleanup