Fixed logic errors with IR sensing.