Improve update script

Various fixes and improvements to updater script.