Fixes to imapHandler