CLOUDSTACK-7389: fix for the script bugs CLOUDSTACK-7389, CLOUDSTACK-7390 and few
other fixes.