Fix a couple of bugs with the cycle creation code.