Small improvements

Hi!

I did some small improvements to your library. Mainly some possible NPEs are now avoided and it is possible to use this lib more asynchronously than before.