Fix previous fix (a91d8af3f0f67b62ad5ff28245c16a7be05967c2), and close #56. Thanks to @neovatar for reporting this, and for doing a lot of the hard work!

Bump version to 0.5.1.