Final fixes for #1312
Fixes #1319