Remainder of fix for #506