Fixes for #397 and #406