More commenting for completeness

Commented each block to clearly explain what is happening.