Improved code performance (Math.Pow(x, 2) replaced with x * x and simila...

...r cases).

Code formatted.