A bit of work on the database stuff