Added back first level recursion detection code