Preheat the oven to 180ºC (350ºF). Chop the onions, carrots and celery into small dice (approx 1/2cm). Crush or grate the garlic. Dice the mushrooms. Rehydrate the porcini mushrooms by soaking in 1/4 cup (60 ml) boiling water for 5-10 minutes, then drain and chop finely, reserving the liquor.
In a large, heavy bottomed pan, heat the oil and then sauté the diced veggies, with a pinch of salt, for about 5 minutes until softened. Add the garlic to the vegetables and cook for about a minute. Add the mushrooms, porcini and the leaves from the thyme sprigs and cook for 4-5 minutes over medium high heat until their juices have evaporated.
Rinse the lentils and add them to the pot along with the vegetable stock, bay leaves, yeast extract (if using) and the porcini soaking liquid (taking care not to add any grit left at the bottom). Bring to the boil and then simmer, partially covered, for approximately 25 minutes or until the lentils are just tender. You might need to add more stock or water, depending on how much is absorbed during the cooking process - I added an extra 100 ml (~1/2 cup). Taste and season as required, depending on the saltiness of your stock and whether or not you used yeast extract. I didn't need to add any salt, but added lots of pepper. Stir in the chopped parsley and remove the bay leaves.
Slice the sweet potatoes using a mandolin or as thin as you can using a sharp knife. Starting and ending with sweet potato, layer in an ovenproof dish (mine measured about 11"x8"). I got two layers of lentil mixture. Top with as much or as little grated cheddar as you like and bake for 40 minutes until the sweet potato is tender and the top is golden.