Added some comments to rather vague sections of code.