Ok so from the diagram, you need parts 1,3,4,5,6,7,8,9, and 10. Your best bet id to find a junked X5 and take the whole assembly. It will be cheaper.
Your MAF may have been faulty in the beginning, causing those codes to be thrown. Hopefully you got an OE MAF and not something off ebay or an aftermarket. Those never seem to work.\
That hard black plastic hose is a breath tube for the transmission, it doesn't connect anywhere. It belongs under the Acoustic cover.
The hooked hard plastic black pipe in the back is the breather tube for the Transfer Case.
SOmeone else will chime in and be more specific about the codes.