only perform a database look up for bare JIDs. Return direct to full JIDs or just domains.
Make code easier to read
Tidy up code
Merge pull request #233 from surevine/issues/232

Only perform a database look up for bare JIDs