Improved sample
Bug fixes