Fix double-encoding bug