I had the same code which bothered me for a few months. Replaced the MAS and the code came back after a couple of drive cycles. To make the long story short, it turned out that I had a leaking air intake. I don't know what to call this piece but it's a flap that controls air into the engine on the top right hand side of the engine. it's held in place by 4 hex screws. The flap was broken and was leaking air thus giving me the P0170 code. This may not be your problem but it's worth a try.