a lot of clean up and fixes