added some comments and some minor tweaks according to read pages of api reference.