Update error checks, remove debug code.