Clean up and unify protocol error handling