Move protocol functionality to separate file.