Add some log and fix a bug.