Implemented Square Magnitude

Switched all instances of magnitude distance checking with square
magnitude distance checking (more efficient to do a square than a square
root).