Bug fixes for parsing emails