Fixed script destructor and free resource struct when done.