No need to sort MIME messages by ID
Look only for "begin " for non MIME messages

666 is UNIX permissions and can be 644 or anything else.
forgot to fix comment
Greatly improve message sanity checking for non MIME messages
Improve some regular expressions
Print ID of non MIME message in debug