Bugfix for issue #37

To be honest, I don't have a high degree of confidence in this bugfix. However, it does appear to fix issue #37 (again).

Feedback wanted.