Completed IMAP implementation