There should be a ground from the battery to the block and a somewhat flimsy strap from the back of the head off one of the head bolts to the firewall. That strap tends to fall apart over time and cause the symptoms you describe. I would suggest adding another strap from the battery to the fender or firewall. Also have a look at Cruiser54s writeup for the ground point under the dash as well.

For the headlights, consider installing a few relays driven by the headlight switch. The oem headlight wiring and the switch were under-designed and drops a fair amount of voltage even when it works. The upgrade will help the stock headlights and are needed if you want to go brighter. A set of drop in autopal e-code housings from eBay for $30 will also help immensely. I run napa house brand 55/100 H4 bulbs in mine and have great long distance deer spotting highbeams, and low beams with a great cutoff that don't blind oncoming drivers.

Very useful information on the e-codes. I ran e-code lenses on my Volvos and the difference was very noticeable. I'll be picking up a pair for the XJ. Regarding the relay, so the headlight current flows through the switch? I'm adding relays as well. One for low, one for high.