fixes #503 and fixes #506