add more log output and fix some bugs