Fixes for database upgrades