Fix for issue #18

I've hacked up a quick fix for issue #18. Please merge and deploy.