improved foreign content parsing