fix bugs reported by valgrind
small fix
update README