Refactor and solve encoding issues.