Manually patch applied from pull request #16 (cannot rebase automatically)