fix bug in upgrade and other refinements and more error msgs