fixed foreign keys/added main controller