Updates and small fix

Hey,

Thank you for developing this. I tried to get the version in your repository to compile with the latest updates, and it failed. To fix this, I merged in updates from freedesktop.org, and applied a tiny fix that seemed to have solved a segfault I was getting while testing.