Improve IMAP/POP3 code, fix compiler error.