Moved the protocol structures and functions into their own module. Also added a leaner type for interfacing with the C api.