Fixed encoding bugs.