lots of clean up and commenting