several minor bugs fixed