The biggest speedup is to make a constant version of the stuff in userfunction and to use that for mcmc. This should be done automatically but was never got to.