Put the flaxseed into a glass with the water and set aside to thicken. Preheat the oven to 400°F (200° C). Line a loaf tin with greased parchment paper, and set aside.
Wash the lentils well and transfer them to a medium-sized saucepan with the the vegetable stock. Bring to a hard boil, reduce the heat and simmer over low heat until the water has been absorbed and the lentils are cooked, about 25-30 minutes. Drain off any excess water (there should not be much.)
Heat the olive oil in a saute pan and add the onions, carrots, celery, garlic, rosemary, cayenne, mace and salt. Saute until soft (5-8 minutes.)
Toast the sunflower seeds in a heavy bottomed pan, moving them around for a few minutes until they release their aroma. Make sure they don't burn. Transfer the seeds to a food processor along with the rolled oats and pulse until they are the consistency of a course meal.
Add half the lentils, rolled oats, and sunflower seeds to the pan with the vegetables, and mash the mixture with a masher or a wooden spoon.
Add the reserved whole lentils and the flaxseed egg replacer to the mixture and stir gently. Adjust the seasoning.
Pack the lentil mixture into the prepared loaf tin with the back of a wooden spoon.
Mix together the ketchup, balsamic vinegar, maple syrup and onion powder. Spread it over the lentil loaf and bake for 40-50 minutes.