major improvements for database class