Regarding the timing chain/top end rattle, it could simply be the decompression mechanism. Incorrectly aligned and/or loose decompression pins are a known problem on the XT660. Have a read of this thread:
http://www.xt660.com/showthread.php?t=24187
As for the random non-starting and dead clocks, the first thing I'd do with any intermittent electrical fault is get the tank off a go through the wiring and connectors very carefully. It is not unknown for older XTs to suffer badly from corroded connectors/terminals and for wires to rub through on various parts of the frame. Even the blade fuse contacts can become furry and make intermittent poor contact - pull them out and clean them. Check the battery terminals are tight and all earthing points are god and free from corrosion.