Added acyclic check.