Mixed mode bugfix

Fix for issue #3022. It worked in my particular case. 

If you want me to write a unit test, can you please direct me to which test it might fit in?