modify log reading and fix some bugs