Sampler code has been modularized

Sampler code has been broken into smaller parts