Fix various script errors