Implement reference cycles detection