Fixes #705

This is my contribution. I did some testing, and it seems to be working fine, but of course is your project some you should know better.