Fix upgrade bugs. Hope this will definitely get rid of them.