Bug fix + example + minor naming change

I'm using this library in one of my projects and noticed some problems.
Since this repo doesn't seem to be very active (I don't even know if my changes are gonna be useful to someone), I put everything in the same PR.