Refactor so that less stuff is O(n) when in the interpreter.