improve complex inv. fixes #5188

also simplify division code a bit