Fixes for #247, #248 and #249