   delay(50); // Poll every 50ms
 }
 
-void process(YunClient client) {
+void process(YunClient& client) {
   // read the command
   String command = client.readStringUntil('/');
-  
-  int i=0;
-  while(1){
-    if(http_endpoints[i].cmd == 0)
-      break;
-    
-    if(command == http_endpoints[i].cmd){
+
+  // handle /state with no trailing /
+  if (command[command.length() - 2] == 0xD && command[command.length() - 1] == 0xA) {
+    command = command.substring(0, command.length() - 2);
+  }
+
+  int i = 0;
+  while (1) {
+    if (http_endpoints[i].cmd == 0)
+      break;
+
+    if (command.equals(http_endpoints[i].cmd)) {
       http_endpoints[i].func(client);
       return;
     }
-  }
-}
-
-void eventCallback(StatusEvent event){
-  switch(event){
+
+    i++;
+  }
+  client.println(F("Status: 404"));
+  client.println();
+  client.println(F("{\"error\":\"Command not found.\"}"));
+}
+
+void eventCallback(StatusEvent event) {
+  switch (event) {
     case EVENT_LID_OPENED:
       Serial.println("EVENT: LID Openned.");
       sendEvent(EVENT_LID_OPENED);

void loop() {
  // handle slow cooker functions.
  slowcooker.loop();
  
  // Get clients coming from server
  YunClient client = server.accept();


}


void sendEvent(StatusEvent event) {

}

void handle_state(YunClient& client) {
  Serial.println(F("Handle state"));
  client.print(F("{\"cookTime\":"));
  client.print(slowcooker.CookTime());
  client.print(F(",\"cookTimeLeft\":"));
