Core resets sometimes using interrupts(?)

Tried using code from here. [Solved] Trying to port an AC Dimmer circuit from Arduino to SparkCore

Well it works in a stable way, but it does not fully dim lights for me(only half-way) and have flickering issues even on incadesent bulbs. No such issues with original code.