Added a better square decomposition algorithm using quadratic residues.