encoding decoding improvements