fixed better db-support and bug fixes for database.