Fixes issue #998.
Merge pull request #1008 from ne0fhyk/fix_issue_998

Fixes issue #998.