Fixed a bug that made script lose data while running.