Fixed formatting.
Added CheckErrors method. Renamed GetSamples to ReadSamples and added generic overload. Improved error checking code.