Lots of cleanup, and change for cleanup in NCommon as well