Clean up and fix encodings