fix encoding bugs.