Fixes recursion bugs