Revert "Revert "Merge pull request #7 from michaelwu/bug-979625""

This reverts commit 7ec4072f40232f00c722bc7495e19e05c5b175b2.