Insert comments

Just added some comments to some of the existing JS functions that are
heavily used.