Fixes for #2040