Fixed a lot of bugs. The imaginary quadratic case works quite well now.