Does it seem to be that your feet are swelling a little near that 40 mile mark?
Thinner socks might help. When I had that real bad a long time ago I even wore some very sheer nylon women's socks to help with that. Eventually I found that ensuring I was getting plenty of fluids while on the ride helped. And then after that, whenever I feel that swelling and pain start to develop, I drink extra water while on the bike till it goes away. Though it doesn't happen much anymore since I hydrate well now.