Corrected a few error checks