fix recursion depth: some algorithms