reorganize protocol handling -- work in progress