Fixed reentrance problems with scripts.