Move protocol handling to base module