More comments and minor code changes