If I were diagnosing this I would pay very close attention to the wiring to the thermostat that you said had some damage. I have seen an N52 powered X-drive model with broken passenger side engine mount bracket bolts which caused the engine to drop down just enough to pinch the t-stat wiring causing a short to ground and messing up all kinds of stuff including getting BSD faults. If the wiring looks like it was impacted/smashed I would repair it there and possibly ohm it out from the t-stat up to the DME to be 100% certain you aren't chasing a harness issue. If it's losing connection or shorting out it could be an intermittent issue like you are describing.
Most likely i did the damage to the lead to the thermostat when i removed it the first time. I had a hard time removing the thermostat since the guide i used for the wp replacement mentioned to pull the thermostat out towards the radiator.
When i did this i most likely pushed the lead from the thermostat onto a sharp edge of the subframe and peeled away some of the insulation.
None of the copper wires that forms the lead have been damaged and what i did now to fix it was simply putting a new shrink sleeve that was prefilled with something similar to glue, so when you heat it i can basicly press on it with my fingers and seal the whole thing of.
Yesterday i also removed the fan to make more room to try and find any damage to any wires to the wp or thermostat, without finding anything..
Although how would a fault thermostat cause 2e81 and 2e82 codes? Even if the thermostat would be broken/open/closed, there would still be flow from the wp?
What i have done now, to be 100% of the flow of the wp is simply connecting INPA to the car once i see temperatures skyrocket.
When i have inpa connected i can very the speed of the pump and once temperatures skyrocket the pump is dead, it shows 0%.
It does not matter if i then clear the codes, the fault is still there and pump speed is 0 until i leave the car for the night and come back in the morning. In the morning the WP seems to be working again, most likely due to the fact that everything has cooled down.