added comments and general fixups