Fixed bugs, write OK, close OK