various script stability tweaks