Fix #309 and #69
Merge pull request #318 from aesedepece/fix-for-issue-69

Fix #309 and #69