Fix for issue #276. Thanks @kprovance