Merge some improvements by Purodha.