Port script fixes from 1.7.10