lots of cleanup and formatting