Code cleanups and comments