Moved some functions out of backup and into database where they belong