Changes to the way indexing works in order to allow more pre-run optimization, including external functions.
Fixed some error reporting tests that were failing earlier due to new optimizations.