fixed issue #1080
code cleanup.
Merge pull request #1194 from ne0fhyk/fix_issue_1080

Fix issue 1080