Converted all data reads to use safe read methods.
Fixed memory leak on failure in read.