lots of cleanup and changes