Starting out with an engine flush ain't a bad idea. Liqui-Moly Engine Flush is what I've used and it pulled a LOT of gunk. Buy some cheap oil (I used Kirkland Signature I found on sale) and a handful of filters. Run the flush following the instructions, drain and swap filter, then flush the flush with yet another oil change. Then do a final fill and filter change, using the oil you really want to use. That first drain I did and that oil was BLAAAAAACK! After doing my head job, I was also getting VVT solenoid codes and had to do a series of solenoid flushes, where a bunch of metal came out of those filter screens, and ultimately had to change one or both of them altogether (I forget). Took another oil change or two and the codes totally went away, never to return. Probably a matter of cleaning up the internals and shaking out the cobwebs in the VVT units.
As for the rattly noise, it can be any number of things. Do you have a mechanic's stethoscope? They have them cheap at ye ole Harbor Freight if you don't. Might help to pinpoint the noise. Could be a simple belt tensioner, maybe something with the VVT. There's no telling without further investigation. I've had bad rattling resolved with simple upper motor mount changes. Tough to say over the interwebz without being there.
https://www.liqui-moly.com/en/us/pro...h-p000065.html