Patch for issue #12?

In an attempt to not just report the bug, here's a stab at fixing the problem as well :-)

I'm not sure if this is the preferred way to fix a problem like this, but at least you can pull this small fix down and test it, to see if fixes the problem - and then maybe do the necessary refactoring?

/Chriztian