Loads of JSDoc commenting and a couple fixes I spotted along the way.