lots of refactoring for versioning