Add some extra log messages.
Fix a bug.