Fixes #380 and #378