Fixes #503 and fixes #497