Mostly refactorings. Moved functionality from static methods to classes,
this seems much more tidy.