bunch of features and fixes for database library