several bugs fix