As for WD40
I would not recommend using WD40 on bicycle chains and here's why.....
WD40 will work to clean a chain, but was designed to displace moisture and is quite good at it. WD40 is very persistent and will remain in the nooks and crannies of your chain which is not what you want. Since it is also a solvent, it will do it's work on the newly applied chain lube just like it did on the old stuff.
To clean an old nasty chain, use one of the many products out there designed specifically for that purpose. A chain cleaning tool like the Park CM-5 is nice to have too. Use it with soapy water or a citrus based cleaner.
Seriously, if you switch over to R&R lube, your days of greasy, grimy, cruddy, chains will be over. The stuff really works!