Avoid some charset lookups

Background info at e.g. http://bugs.mysql.com/bug.php?id=61105
Remove unnecessary casts
Remove unnecessary semicolons
Add missing @Override annotations
Remove dead code
Merge pull request #1535 from scop/charset-lookup

Avoid some charset lookups
Merge pull request #1536 from scop/cleanups

Various cleanups