Move "create table" logic to a reusable function.
Make dependenciesLookup pass its result rather than mutating globals

Instead of dependenciesLookup modifying the global "table" var, have it
return its results in the callbacks.