Clean up.
Convert functions to use explicit closures.
Differentiate internal errors from compile errors.