Some changes for bidi support