Fixed a helper function
Handling of complex coefficients improved