2 codes in 1 software

Can't say without seeing all your code (post it all, please), but at a guess you may have declared time as an int instead of an unsigned long. At least that is what usually causes weird behavior during the first 30 seconds after startup.

-br