Revert "Fix for issue #315"

This reverts commit 4ef3b17300523a79ebfa3a7221eb5803d42d4129.
Revert "Revert "Fix for issue #315""

This reverts commit e4c2332657a50335c20ce56771ef2ebcfc97a2d2.