Zero-crossing in AC with DC offset signal
The comparator from the zero-crossing detection has an RC time constant at the output that defeats the purpose of having a clean pulsed output. If there is noise  and needs to be filtered, you can still keep the RC but with a much lower value for the capacitor. As it is, the time constant is 10ms, which is too high, since it is comparable to the input's period. This is what happens to the signal:



The green trace is with \$\tau\$=10ms. red with 1ms, blue with 0.1ms, and black with 10\$\mu\$s. Depending on the present noise, you can reduce the time constant to a minimum such that it leaves the pulses as clean as possible, to be able to provide the necessary edge triggers for the next stage, while still functioning as it was intended: a zero-crossing detector.

One minor thing to remember is that the LM311, as open collector as it is, has a source/sink current limit for its output stage, so care should be taken that, when going low, the capacitor doesn't discharge more current that it can handle. The datasheet says 50mA, so a quick solution is this (consider the 2N3904 the open collector):



Note that I didn't change the resistor/capacitor values so the time constant shown is double. Change according to your requirements.