Improved sample and fixed bugs