Improve function table ref

Improve the extraction of tables referenced by functions