Fix logic errors.