Improve accuracy of phase calculation. Resolves #1