Simplified cycle detector a bit.