check if xfer_data->tox is not null, before referencing it; Removed unused variables and fixed signed/unsigned warnings