Upstream fixes

truncatePlaintext completely failed on UTF-8 content, so I changed it slightly.