Updated and corrected several bugs in read/write/truncate