Better error checking and handling for malformed packfiles