I started running out of energy on the 6th lap and was totally dead by the 8th
You didn't look too good at the finish, I studied up feeding and re-hydration tactics carefully when I used to race seriously years ago. Even towards the end of the race I had plenty of energy left and did not feel tired. The only thing that let me down was my left knee which was hurting after my crash and my back which was to be expected.
I carried in my Camelbak 2 litres of water with a can of Red Bull mixed in it (a personal favourite but not to everyones taste) - refilled after 2 hours of riding, Torq energy gels, Black Cherry yoghurt flavour - 1 every hour on the hour & in my pit box I had 500ml of Nuun rehydration drink which I swigged half of when I re-filled my Camelbak. Worked well for me. Dehydration seriously affects performance as you have personally found out. This sort of refueling needs to be practised before a race, don't wait until race day to try it and find out you get stomach cramps from a certain type of energy supplement.
With regard to feeding before the race, anything eaten less than 3 hours before is too late. You need to 'carbo load' the day before. Eat loads, and I mean loads of healthy carbs, Malt loaf is brilliant as long as you don't but spread on it, usual stuff like bananas, pasta and jacket potato with baked beans is excellent - no butter on the spud. Go for high carbs, some protein and no fat. Avoid fat altogether if you can, it slows down your carb intake. Drink lots of water, it helps your body store the carbs as energy. Sipping an energy drink thoughout the day helps a great deal.
On the day an ideal breakfast is porridge with banana but must be eaten at least 3 hours before the race. Sip an energy drink to keep you hydrated for the time between breakfast and the race.