Improve script reloading (#949)