fixed cycle detection. the previous one was only suitable for trees not dags. preliminary update algorithm implementation.