fixes #287, fixes #339 - Finally got the cycling logic working correctly (I hope)