added comments, some minor changes