fixed focus issue and "write end dead" problem