To make the pastry, sift the flour together with a pinch of salt in a large bowl. Rub in the butter until you have a soft breadcrumb texture. Add enough cold water to make the crumb mixture come together to form a firm dough, and then rest it in the fridge for 30 minutes.
Roll out the pastry on a light floured surface and line a 22cm/81⁄2inch well-buttered flan dish. Don’t cut off the edges of the pastry yet. Chill again.
Preheat the oven to 190C/Gas 5.
Remove the pastry case from the fridge and line the base of the pastry with baking parchment and then fill it with baking beans. Place on a baking tray and bake blind for 20 minutes. Remove the beans and parchment and return to the oven for another five minutes to cook the base
Reduce the temperature of the oven to 160C/Gas 3.
Sprinkle the cheese into the pastry base and add the sliced tomatoes if you are using them. Fry the bacon pieces until crisp and sprinkle them over the top.
Combine the eggs with the milk and cream in a bowl and season well. Pour over the bacon and cheese. Sprinkle the thyme over the top and trim the edges of the pastry.
Bake for 30-40 minutes or until set. Remove from the oven and allow to cool before serving.