Fix bugs in versioning system