Restored a few of the database functions from HEAD in order to make archive/unarchive work. Those two functions are still delicate.
Changed paths: