fix several minor bugs