Then explaining how to modify and debug it is likely beyond what can be accomplished here. If you have a budget you can post in Marketplace or contact me.
It’s stored in a custom field called “import_id” and there are functions you can use to do lookups that you can see in the code. Something like topic_id_from_import_id()