Code cleanup with some protocol adjustments