First set of fixes for #1141