Implement the fixes from issue #1126.