added comments and other fixes