Tidy up on the db code.