Fix variables which leak into the global context.

The `expressionCode` and `failedIndex` variables should not be global.