Fixing upcasting behaviour

Fixes the bug reported in #76 and some more things in the same vein.

Not done yet, as lots of other operations do not yet work.