added cyclic referencing check, passed some more tests