Fix for issues 1611 and 1621

The commits from March 22, was part of another pull request. They should not be there.