fixes #380 and #365