Streamlined tf-by-doc. Cleaned up other cruft.