Initial support for versioning
A quick rewrite to clean things up