Add debug logging throughout.