Misc error checking and cleanup. Initial prep for bz2 handling.