refactored to use Protocol type
misc fixes