Bug/imap improvements