Fix for #1686

Adding an OR in the query was short-circuiting the logic.  We need to
group things with parentheses.
Fixes for deleted external accounts

Fixed a couple functions so they don't crash if an account is deleted.
Merge pull request #1690 from pculture/deleted-account-display

Deleted account display