Fixes #377 and #378