New Stata test and many bugfixes