This should improve calculation speed and accuracy.

Please review, in particular the long conversion was may necessary.