added more performance to the db and fixed FK's