Fixes #617 and #618