cleanups and better comments