clean up header lines with bad line endings
remove array deref from imap lib
misc js tweaks and fixes