fixed a couple bugs in database update code