bugfixes for both issues in issue #26