This should fix issue #1

Needs testing but should work.