Fixes #560

Please see the error explanation of #560 and the commit messages.