Adds reference table class
Adds logic for avoiding cycles in the ref table