Watch this Author's files
I got this as a reference and guide as I attempt to write my own Quadratic Sieve.
I noticed an issue on your legendresymbol. I think you have the 'iseven' check under p==2 backwards.
for instance: legendresymbol(87463,2) = 0. I expect '1'.
Thanks for such a great toolbox.