Further performance improvements to string encoding