Fixed script bugs.