Totally refuctored (hopefully for the better?) encoding / decoding.