Various small fixed in the lib

It doesn't fix all issues ... but it fixes some :)