removed unused script refs, updated pseudocode