minor code changes, more comments