Fixes for #1006 and more