Problems with bluetooth RN42 and GPS library

Hello. I have already made a succesful data transfer via bluetooth between arduino and an android app. But this time the client wanted the program to display in an LCD the connection status, so I wrote a routine that constantly (first in the loop), goes into CMD mode, and checks the connection before exiting it, and it works, everytime I connect a device and disconnect it I get the status change in the LCD. The problem is that it doesn't give enough time (I am assuming) to the other data to be read, I send it and send it and ther is no reading, I have tried various things, like puting the routine in an ISR so it checks it every 1 sec, but It just doesn't ever get out of the CMD mode, and it is pasted just like the one that does get out of it, also there is a NAK sign taking the place of the reading before the 0 (Not connected) or 1 (Connected), it works, but this is rare, I don't know where it comes from.

Here is the routine, I won't write the declarations because it will exceed the character minimum

	void loop() {
  
   //Chequeo de estado de conexión del bluetooth
              Serial1.print("$");  //
              Serial1.print("$");
              Serial1.print("$");  //
              delay(100);
              while(Serial1.available()){
                      Cm = Serial1.read();
              }
              Serial1.flush();
             
              Serial1.println("GK");
              delay(100);
                                  
              if(Serial1.available()){
                  BlueStat = Serial1.read();
                  BlueStat = BlueStat - 48;
              }
              
              Serial1.print("-");
              Serial1.print("-");
              Serial1.print("-"); //Exit command mode
              delay(100);
              while(Serial1.available()){
                  En = Serial1.read();
              }
              Serial1.flush();            
    
              delay(1500);
              Serial.println(BlueStat);
              if(BlueStat == 0){
                  lcd.setCursor(0, 1); lcd.print("**No Conectado**");
              }
              if(BlueStat == 1){
                  lcd.setCursor(0, 1); lcd.print("***Conectado***");
              }
              
              //Se chequea si se han recibido datos o si es pulsado el botón 1 para pruebas                
              if(Serial1.available() || digitalRead(Bot1) == HIGH || Estado == 1){
                  DatoA[0] = Serial1.read();                        
                  Serial1.flush();                                  
                  Command = DatoA[0];                               
                  delay(50);
                  ia = 0;
                  if (Command == 'N'){
                      Serial1.flush();
                  }
                  if (Command == 'A'){
                        for (i = 1; i < 20; i++){
                              if(Serial1.available()){        
                                    DatoA[i] = Serial1.read();            
                                    Serial1.flush();
                                    delay(30);
                              }
                        }
                  }
                  i = 0;
                  //Serial.println(Command);
                  
                  // Si el dato recibido es una A y el reloj no ha arrancado
                  if ((Command == 'A' || digitalRead(Bot1) == HIGH) && Estado != 1){
                        Estado = 1;
                        IniciarConteo();                                                                 
                  }
                                    
                  // Si el dato recibido es una X y el reloj está contando
                  if ((Command == 'X' || digitalRead(Bot2) == HIGH) && Estado == 1){
                        DetenerConteo();                                                            
                  }
                  
            }
              
              while(Serial3.available()){
                             int c = Serial3.read();
                                //Serial.write(c);
                                if(gps.encode(c)){
                                    gps.f_get_position(&Latitud, &Longitud);
                                    gps.crack_datetime(&ano, &mes, &dia, &hora, &minutos, &segundos, &centesimas);
                                                       
                                }   
                   }                                                         
                                Serial.print("Latitud: ");
                                Serial.println(Latitud,5);
                                Serial.print("Longitud: ");
                                Serial.println(Longitud,5); 
                                if(minutos >= 30){
                                    minutosre = minutos - 30;
                                    horare = hora - 4;
                                }
                                if(minutos < 30){
                                    minutosre = 60-(30-minutos);
                                    horare = hora - 5;
                                }
                                if(minutos < 5 && minutosre > 18){
                                    diare = dia - 1;
                                 }    
                                Serial.print("Fecha: "); 
                                if(dia < 10){
                                    Serial.print("0");          
                                }   
                                Serial.print(dia, DEC); Serial.print("/"); 
                                if(mes < 10){
                                    Serial.print("0");  
                                }
                                Serial.print(mes, DEC); Serial.print("/"); Serial.println(ano);
                                Serial.print("Hora: "); Serial.print(hora, DEC); Serial.print(":"); Serial.print(minutos, DEC); Serial.print(":"); Serial.println(segundos, DEC);
                                Serial.print("Hora: ");
                                if(horare < 10){
                                    Serial.print("0");
                                }
                                Serial.print(horare, DEC); Serial.print(":");
                                if(minutosre < 10){
                                    Serial.print("0");
                                }
                                Serial.print(minutosre, DEC); Serial.print(":");
                                if(segundos < 10){
                                    Serial.print("0");
                                }
                                Serial.println(segundos, DEC);

}

Without this new routine (which works fine alone), the rest of the code works fine.

Also, the GPS encode routine is not completely working, and as you can see it is almost the same as the one below, which works perfectly, and the one above is executing in the main loop so it can be checked constantly. I am thinking in migrating to Atmel Studio and dowloading ann arduino plug in so I can debug it in there, but if you can helpe in some way I would appreciate it very much.

#include <TinyGPS.h>

TinyGPS gps;
float Latitud;
float Longitud;
int ano;
byte mes, dia, diare, hora, horare, minutos, minutosre, segundos, centesimas;


void setup(){
  
  Serial.begin(9600);
  Serial.flush();
  Serial3.begin(4800);      
  Serial3.flush();
  delay(500);

}


void loop(){
  
  while(Serial3.available()){
      int c = Serial3.read();
      Serial.write(c);
      if(gps.encode(c)){
          gps.f_get_position(&Latitud, &Longitud);
          gps.crack_datetime(&ano, &mes, &dia, &hora, &minutos, &segundos, &centesimas);
      
          Serial.print("Latitud: ");
          Serial.println(Latitud,5);
          Serial.print("Longitud: ");
          Serial.println(Longitud,5);
          
          Serial.print("Fecha: "); 
          Serial.print(dia, DEC); Serial.print("/"); 
          Serial.print(mes, DEC); Serial.print("/"); Serial.println(ano);
          Serial.print("Hora: "); Serial.print(hora, DEC); Serial.print(":"); Serial.print(minutos, DEC); Serial.print(":"); Serial.println(segundos, DEC);
            }
  } 
}