more code clean up and comments