Distributed cycle detection and removal