Fixes for issues raised in #1279

All mentioned issues in #1279 should be now resolved with this pull request and #1380.