Further changes to the database code