Fix encoding chaos