Restore performance optimizations lost in previous commit