You probably ran out of memory. You use a lot of print/println calls without using the F() macro (holds the strings in the flash without using the same amount of RAM). And you're using the String class. Although the worst bug in it is fixed in version 1.0.5 of the IDE, it's still a bad choice for sketches that have to run reliably for a longer time because it uses dynamic memory allocation. That way the memory gets fragmented until there isn't a memory area of the requested size. At that point the results get erratic and your sketch isn't working in a predictable manner anymore.