Still room for further improvement. Includes some fixes for regressions introduced with previous commits.