Replaced the incorrect Abs()/Max() operations with squared magnitude checks via dot products
See here