Minor code cleanup for IMAP