Tookit to optimise functions defined at runtime.