           if (strcmp(toks, "read") == 0) {
             toks = strtok (NULL, "/");
             if (strcmp(toks, "datastreams") == 0) {
-              sendContent(request);
+              writeHeader(request, JSON_RESPONSE);
+              writeDataStream(request);
               break;
             } 
             else if (strcmp(toks, "switch") == 0) {
-              sendContent(request, digitalRead(RELAY_PIN));
+              writeHeader(request, JSON_RESPONSE);
+              request.print("[");
+              request.print(digitalRead(RELAY_PIN));
+              request.print("]\n");
               break;
             } 
           } 

  Serial.print(delta);
  Serial.print(",");
  Serial.print(sleep);
  #ifdef NOETH
    Serial.print(",");
    Serial.print("-");
    Serial.print(",");
    Serial.print("-");
    Serial.print(",");
    Serial.print("-");
    Serial.print(",");
    Serial.print("-");
    Serial.print(",");
    Serial.print("-");
    Serial.print(",");
    Serial.print("-");
  #else
    Serial.print(",");
    Serial.print(Ethernet.localIP());
    Serial.print(",");
    Serial.print(SERVER_PORT);
    Serial.print(",");
    for (byte thisByte = 0; thisByte < 4; thisByte++) {
      // print the value of each byte of the IP address:
      Serial.print(settings.host[thisByte], DEC);
      if (thisByte < 3) {
        Serial.print(".");
      }
    }
    Serial.print(",");
    Serial.print(settings.port);
    Serial.print(",");
    Serial.print(settings.feed);
    Serial.print(",");
    Serial.print(settings.apikey);
  #endif
  Serial.print("\n");  

}

      settings.r1 = value;
    } 
    else if (cmd == 'B') {
      settings.r2 = value;
    } 
    else if (cmd == 'C') {
      settings.offset = value;
    } 
    else if (cmd == 'D') {
      settings.sensitivity = value;
    }
    else if (cmd == 'S') {
      if (value > 0) {
        digitalWrite(RELAY_PIN, HIGH);
      } 
      else {
