some changes for bidi support