use lengthSquared() rather than length() in updatePath()
some cleanup.