More database interaction fixes