[Database] Fixed broken code. Various updates.