Problem with IR receiver

It's kinda long that's why I didn't post it all at once...just the IR parts are bothering me everything else works fine...this is it:

#include "Ultrasonic.h"
#include <IRremote.h>

//DHLWSH METAVLHTWN

Ultrasonic ultrasonic( 12, 13 );
int x,s1,s2,s3,s4,g1,g2,onoff,dist1,dist2,k,x5144,x4539; //x:distance,s1:speed,g1+g2:apenergopoiites,dist:epithimiti apostasi
  const int motor1Pin1 = 9;    // H-bridge leg 1 (pin 2, 1A)
  const int motor1Pin2 = 10;    // H-bridge leg 2 (pin 7, 2A)
  const int motor2Pin1 = 5;
  const int motor2Pin2 = 6;
  const int enablePin = 8;  // H-bridge enable pin
unsigned long t1,t2,t3,t4,tt,p1,p2,ir; //t1,t2:xronoi gia freno,p1,p2:xronoi allagis s1,ir:received button

int right_ldr = 1;//analog pin to which LDR is connected
int left_ldr = 2; 
int right_value = 0;        //variable to store LDR values
int left_value = 0;
int x4439;
int x5145;

int RECV_PIN = 7;
IRrecv irrecv(RECV_PIN);
decode_results results;

//TELOS DHLWSHS METAVLHTWN

void setup()
{
  Serial.begin( 9600 );
    pinMode(motor1Pin1, OUTPUT); 
    pinMode(motor1Pin2, OUTPUT);
    pinMode(motor2Pin1, OUTPUT);
    pinMode(motor2Pin2, OUTPUT); 
    pinMode(enablePin, OUTPUT);
    digitalWrite(enablePin, HIGH); 
    s1=0;
    g1=0;
    g2=0;
    irrecv.enableIRIn(); // Start the receiver
    ir=0;
    onoff=0;
    dist1=41;
    dist2=30;
    x4539=0;
    x5144=0;
}

void loop()
{ // RECEIVED IR
  if (irrecv.decode(&results)) {
    ir=(results.value);
    irrecv.resume(); // Receive the next value
  }
  // EPEKSERGASIA IR
  if (ir==16720605) {
    onoff=1;
    s1=85;
    s2=86;
    delay(100);
    ir=0;
  }
  
  if (ir==16753245) {
    onoff=0;
    s1=0;
    delay(100);
    ir=0;
  }
  
  if (ir==16761405) {
    ++dist1;
    ++dist2;
    delay(100);
    ir=0;
  }
  
  if (ir==16712445) {
    --dist1;
    --dist2;
    delay(100);
    ir=0;
  }
  
  if (ir==16748655) {
    ++s2;
    ++s2;
    delay(100);
    ir=0;
  }
  
  if (ir==16754775) {
    --s2;
    --s2;
    if (s1>s2) {
      --s1;
      --s1;
    }
    delay(100);
    ir=0;
  }
  //TELOS IR
  

      
  //ULTRASONIC
  
  x=ultrasonic.Ranging(CM);

  //TELOS ULTRASONIC
  
  right_value = analogRead(right_ldr);
  left_value = analogRead(left_ldr);  

  if (onoff==1){
    
    if (right_value<220){
      if (left_value<500){
        s3=0;
        s4=0;
      }
      else if (left_value>500) {
        s3=0;
        s4=200;
      }
    }
    else if (right_value>220) {
      s3=200;
      s4=0;
    }
  
    
  
      // FRENO
  if (x>40) {
     k=0;
     x5144=0;
     x4439=0;

  }
  if (x<41) {
  
  if (x<41&&x>30){
    if (x5144==0){
     t3=millis();
     ++x5144;
    }
  }
  if (x<31&&x>20){
    if (x4539==0) {
     t4=millis();
     ++x4539;
    }
  }
  if (x<20){
    x5144=0;
    x4539=0;
    tt=(t4-t3);
    
  if (tt<1000) {
    if (k==0) {
     analogWrite(motor1Pin1, 0);
     analogWrite(motor1Pin2, 0);
     analogWrite(motor2Pin1, s3);
     analogWrite(motor2Pin2, s4);
     delay(200);
     
     analogWrite(motor1Pin1, 0);
     analogWrite(motor1Pin2, 80);
     analogWrite(motor2Pin1, s3);
     analogWrite(motor2Pin2, s4);
     delay(1000);
     
     analogWrite(motor1Pin1, 0);
     analogWrite(motor1Pin2, 0);
     analogWrite(motor2Pin1, s3);
     analogWrite(motor2Pin2, s4);
     
     ++k;
     onoff=0;
     
  }
  }       
}
} // TELOS FRENOU
  
  // AYKSOMEIWSH APOSTASHS
  if (x>dist1) {
   if (s1<s2) {
   if (g1==0){
      t1=millis();
      ++g1;
      }
      p1=(millis()-t1);
      if (p1>200) {
        ++s1;
        g1=0;
      }  
} 

     analogWrite(motor1Pin1, s1);
     analogWrite(motor1Pin2, 0);
     analogWrite(motor2Pin1, s3);
     analogWrite(motor2Pin2, s4);
  }
  else if (x<dist1&&x>dist2){
     analogWrite(motor1Pin1, s1);
     analogWrite(motor1Pin2, 0);
     analogWrite(motor2Pin1, s3);
     analogWrite(motor2Pin2, s4);
  }
  else if (x<dist2){
    if (s1>30){
    if (g2==0){
      t2=millis();
      ++g2;
      }
      p2=(millis()-t2);
      if (p2>200) {
        --s1;
        g2=0;
      }
      
     analogWrite(motor1Pin1, s1);
     analogWrite(motor1Pin2, 0);
     analogWrite(motor2Pin1, s3);
     analogWrite(motor2Pin2, s4);
  }}}
  // TELOS AYKSOMEIWSIS
  
  // APENERGOPOIHSH
  if (onoff==0){
     s1=0;
     analogWrite(motor1Pin1, 0);
     analogWrite(motor1Pin2, 0);
     analogWrite(motor2Pin1, s3);
     analogWrite(motor2Pin2, s4);
  }
}