several minor bugs fix