Fixes #332 and #327