Changed database structure to flat