Bug fix: buffer is not allocated.
Bug fix: sampling count is computed automatically from a capacity of supplied buffer.