removed heap alloc of receivedSamples; cleaned up code