latest code changes.  added comments and fixed a couple issues.