How about adding serial print statements in strategic places so you can follow what the code is doing,?