IMHO, and even if I agre with the previous suggestions, it Shouldn't be that messy since you have nothing in the mainloop. Do you have a square wave signal generator (or anything who can produce 50/60 hz with TTL logic level)? try it. If it works, you may have to rethink about your zero crossing circuit.