Added in full comments to code, should be easier to pick up and modify later now