Fixed memory issues in getNthFunctionDefinition