Error-checking added.
Fixed I/O bugs for large datasets.
Minor fixes.