Added comments and some cosmetic changes