sampleMine's updated, functions from master copied to here.