codechanges and bugfixes inside class.database.