Move email lookup to util function

Since multiple email addresses can be registered, use a
utility function to look up the "primary" email address.
If no primary email address is set, use the last email address
created.

Fix the tab-space formatting in the preflight files
(it was mixing tabs and spaces, ugh)