fixed several minor bugs