Refactored a lot of stuff, first draft for trigger based versioning