Added comments and minor fixes