0.6.5 fixes

Can't really say I understand what is happening here, so please take this hackish fix with a grain of salt.
Maybe it can be used as a base for further investigation. At least it works for me in 0.6.5 now.