Fixed GitHub issue #27 by applying zeux's patch.