Add variance option to the code. Add try to get non-invertible functions. Enable just in time compiling to simulation for speedup.