Fixes #310 and #250