Bugfixes for issue #1122