fix several bugs...