fixed head matching bug for source nested in a circle (debugging is now switchable at runtime too)