Added some comments to critical sections of the code