Controlo de relés através da web com shield enc28j60

Fiz um sketch para controlar relés através da web com uma shield enc28j60. Consigo ligar-me ao arduino e alterar o estado dos relés, mas após algumas interações (5 ou 6) o arduino bloqueia (deixa de carregar a página). Se alguém me puder dar uma dica e/ou sugestão agradeço.

#include "etherShield.h"
#include "ETHER_28J60.h" //simplified lib do Simon Monk
#include <stdio.h>

static uint8_t mac[6] = {0x54, 0x55, 0x58, 0x10, 0x00, 0x24};
static uint8_t ip[4] = {xxx, xxx, xxx, xxx}; //alterar por um IP válido na rede local
static uint16_t port = 80;

ETHER_28J60 e;
#define maxrelays 10 //máximo de relay a controlar + 2

void setup()
{ 
  e.setup(mac, ip, port);
  for(int(relay)=2;relay<(maxrelays);relay++) //começo no 2 para não usar os pino rx e tx do arduino
  {
    pinMode(relay,OUTPUT);
    digitalWrite(relay,HIGH); //o relé desliga com o pino a HIGH
  }
}

void loop()
{
  char* params;
  while (params = e.serviceRequest())
  {
    e.print("<html><head><title>Web Controlled Relays</title></head><body><table  border=\"1\" width=\"20%\"><tr><td>Relay</td><td>Status</td>");
    for(int(relay)=2;relay<(maxrelays);relay++)
    {
      char resp[3];
      sprintf(resp, "%s%d","?", relay);
      if (strcmp(params,resp) == 0) digitalWrite(relay,!digitalRead(relay));
      if (strcmp(params,"?allon") == 0) for (int(relay)=2;relay<maxrelays;relay++) digitalWrite(relay,LOW);
      if (strcmp(params,"?alloff") == 0) for (int(relay)=2;relay<maxrelays;relay++) digitalWrite(relay,HIGH);
      e.print("<tr><td>");
      e.print(relay);
      e.print("</td><td><a href=?");
      e.print(relay);
      e.print(">");
      if (digitalRead(relay)==LOW) e.print("ON");
      if (digitalRead(relay)==HIGH) e.print("OFF");
      e.print("</a></td></tr>");      
    }
    e.print("</table>
<a href=\"?allon\">All On</a>
<a href=\"?alloff\">All Off</a></body></html>");
    e.respond();
  }
}

Ao que me parece deve estar ocorrendo algum problema com o cache.
Eu ainda nao tive oportunidade de usar o ethernet shield entao nao conheço as funcoes direito.
Entre no site e vá na biblioteca do ethernet shield e veja se tem alguma funcao como a flush do serial para esvaziar a pilha.
É apenas um chute, mas acho que deveria tentar.
Quando resolver posta a resposta pra quando alguem tambem estiver com o problema conseguir resolver.

Não estou a utilizar uma ethernet shield...
A shield que uso é baseada no pic enc28j60 e estou a usar as libs ethershield (nuelectronics) e ETHER_28J60 (Simon Monk).

Vou continuar a investigar para ver se descubro mais alguma coisa.