Smarter truncation. Fixes #1.