Fix minor bugs with database api