Use helper encode/decode functions. #216