code cleanups and comments