Fix bugs, add logs