Various bug fixes.
Merge pull request #7 from emersion/master

Various bug fixes.