Fixed some database update bugs