added some comments and minor fixes