Finish implementing binary encoding