Fixes #1136. Fixes 1135.
Merge pull request #1159 from mdogan/fix/3.1/issue-1136

Fixes #1136. Fixes 1135.