Made the record linking script MUCH more efficient