added comments and cosmetic changes