Database interaction fixes