removed unused code, simplifications, cleanup