I am surprised that you need to use the temp2 stuff inside the repeat to get it to stop.
Any time laststatuscode changes the rule should trigger and run again. Temp1 will get set based on the new status, and doflash will get changed. You are stopping repeating actions and then it will start a new repeat but only if doflash is true. So it shouldn’t need to check the the status again inside the repeat.
As of last September, there was a bug in the stop repeating actions command. It could fail altogether or sometimes you ended up with 2 repeats running. Bruce looked at it and stated that it was broken and he would work on it. See posts 17 and 19 in this thread.
[Motion sensors, retriggers and race conditions]
Maybe it is still broke?