Tidy up how we access the database