Improved sampler. Minor fixes