moved trait links query outside of main loop
Added script to delete redundant links in case an import goes wrong.