Fix bugs with database calls.