implemented residual sampling, verified calculations
added destructors to the source classes