Recursion fix

and other minor fixes