fixed crashes while upgrading database

sorry for 3 updates in several hours, but hey, it's beta :)