Refactored code to work with refactored protocol-lib. #1