There's lots of missing docblocks. I'll tidy it up more as we gain consensus on changes and approach.