added feature to detect cycle(s) within references. added test cases