Protocol code cleanup