Bugfixes for recursion