Added some extra comments to clearify the code.