bugfixes in upgrade