added comments and other minor changes