Improved cyclical reference detection

Signed-off-by: martin f. krafft <madduck@madduck.net>