Fix a crash and debug duplicate messages