This commit is using the easy fix described at issue #1087. Hopefully the performance overhead is small. closes #1087