Improved stability of library

Very rare crash was found and removed