Some changes to generate_code function

	-Produces binary encoding instead of string
	-Counts length as tree is traversed
	-Uses mask indexed by length to set value