   int spaceIndex = in.indexOf(" ");
   bool toEnd = false;
 
+  if(in.length() < 2) {
+    return INT_MIN;
+  }
+
   if(spaceIndex == -1) {
     toEnd = true;
   }
 
   if(codeIndex == -1) {
-    return -1;
+    return INT_MIN;
   }
 
   if(!toEnd) {

    String toconvert = in.substring(codeIndex + 1);
    return toconvert.toInt();
  }
  return -2;
}

String trim(String in) {
  int spaceIndex = in.indexOf(" ");
  return in.substring(spaceIndex + 1, in.length());
}

int strtoint(String in) {return in.toInt();}

/*
 * This function does not yet have any GCode parsing functionality,

    if(xindex > -1) sX.testSpin(xindex * 80);
    if(yindex > -1) sY.testSpin(yindex * 80);

    if(xindex == INT_MIN && yindex == INT_MIN) {
      out.msg(1, "No parameters/Invalid values for G0/G1");
      return false;
    }

    return true;
  }

  int mindex = getIndex('M', in);

  if(mindex == 114) {
    out.pos(0);
    return false;
  }

  out.msg(1, "Incorrect/Unsupported G-Code entered");
  return false;
}

