More bugfix and improvement for the upgrade.