Fixes #543 and fixes #542