Added some comments and minor changes. No functionality changes