Fixes and improvements

Hi, here some improvements to this library.

hope you can merge it soon :)