Fixes #566 and fixes #563