How do i fix diagnostic trouble codes P0011 and P0021 on a 2001 bmw 740il? on 2001 BMW 740iL

When i turn the car on it makes a loud rattling sound and it sounds like it coming from the section of the engine right above the water pump.Sometimes the sound goes away.I also replaced the spark plugs about a month before this problem started with NGK brand spark plugs part#BKR6EGUP.Could these codes haves something to do with replacing the spark plugs.I also have P0720,P0731,P0734 codes but,my understading is that these codes are transmission related and have nothing to do with P0011 and P0021.

Asked by for the 2001 BMW 740iL
Both fault codes relate to incorrect camshaft timing or camshaft timing control problems.
Potential causes:Defective Camshaft Timing Control Solenoid, Incorrect Engine Timing, Insufficient Oil Pressure, Dirty Oil System.
If you have gone a long time between oil changes it is possible that oil passeges to Camshaft timing control could be sluged up and the condition of oil is important also. May try changing oil and filter but if that does not help I recommend you see a BMW technician.