Port performance optimizations from 1.3.1.  Improve logging.