The gearboxes go bad. Apparently the 5speed goes bad more often than the 6speed. Make sure any prospective cars you go to look at are cold when you see them and test drive. I drove several X5s that would bang and shift hard when cold but this largely goes away when the car warms up. Other than that be sure to have some $ set aside to replace the cheap shitty gaskets and plastic parts that will fail (coolant tank, radiator, power steering hoses etc). If you buy a V8 check that the valve stem seals have been done, without exception. They almost all seem to go bad (symptoms are blowing smoke after a few minutes at idle). Also pull off the vacuum hose and have a nosey inside the brake booster. The seals in the vac pump on the V8 go bad sometimes letting oil into the vac line. The check valve then also fails, allowing for engine oil to get sucked into the booster causing it to fail. It can't be repaired apparently, you have to replace. A new booster isn't cheap. Also removing/replacing booster etc is a big job and you will need to take it to the shop to get it bled - I tried for ages to bleed it at home with but was not able to get it done (even with a pressure bleeder and ISTA/D to cycle the ABS pump to open the valves "bleed procedure"). Also, check the underbody for any signs of coolant leaks near the bell housing. Take a torch and check the weep hole at the front of the engine next to the water pump. If you see coolant your transfer pipe could be failing. Couple hundred in parts, thousands in labour.
Basically don't buy it and expect it to be reliable. Get mechanical warranty if so inclined.