rewrite filename truncation code; ref #53