Fix background.js formatting

Just making everything consistent with regards to indentation, etc.
Also added some other changes - see line notes for info.