Cleanup: refactor recursive fn* handling code for clarity