Propagate current sample count to custom procs, part I

See #168
Propagate current sample count to custom procs, part II

See #168