Major fixes for the library