FYI I moved most of this up into an abstract class in a pending pull request, not sure if it would be better to work of that.