Minor changes to the code. Added comments.