Various improvements: see README.md for details.