Disconnect the negative cable from the battery, ensuring to read the battery disconnection cautions beforehand. Raise and safely support the vehicle, then remove the underbody splash shields. Proceed to remove the complete exhaust system along with the heat shields. Detach the front driveshaft from the transfer box and secure it to one side, followed by the removal of the rear driveshaft from the output flange on the transfer case. Remove the flex-disc mounting bolts and the driveshaft center bearing support fasteners, supporting the center of the driveshaft. Lower the center of the driveshaft enough to disengage the flex-disc from the transfer case flange and tie the driveshaft to the side, taking care not to let it hang unsupported. Support the weight of the engine and transmission from above using lifting equipment, then disconnect the harness connector from the back-up light switch on the transmission. For the N52 engine, disconnect the oxygen sensor harness connectors at the base of the bellhousing and unbolt the connector bracket. Disconnect the harness connectors from the servomotor on the transfer case, and for the N52 engine, remove the Torx bolt from the lower right corner of the transmission, using a thin-walled E18 Torx socket if available. For the M54 engine, remove the cover bolt and the cover. Support the transmission and transfer case on a transmission jack, securing it, then remove the transmission cross member fasteners and the crossmember itself. Lower the transmission jack slowly, allowing the engine and transmission assembly to tilt down slightly, being cautious of engine compartment components. Unbolt the clutch slave cylinder from the side of the transmission without disconnecting the fluid hose, suspending it from the chassis with stiff wire. Remove the shift rod clip and disconnect the shift linkage from the selector shaft coupling, then disconnect the shift console from the top of the transmission and lift out the shift arms. Remove the transmission mounting Torx-head bolts, noting their length and location, and discard aluminum fasteners for the N52 engine. Remove the transmission by pulling it backward until the input shaft clears the clutch disc splines, then pull it downwards, ensuring it does not hang from the input shaft. Before reinstalling the transmission, inspect the clutch, clutch release bearing, and flywheel, checking and repairing transmission seals as necessary. Ensure the dowels on the bellhousing are correctly positioned and replace any damaged sleeves. When reinstalling the transmission with the transfer case, check the fluid levels, use new aluminum fasteners for the N52 engine, and new fasteners for the front and rear driveshafts. If installing a new transmission, transfer parts from the old one and thoroughly clean the input shaft and clutch disc splines of old grease, lightly lubricating the transmission input shaft splines before installation.