Fix encode errors