Performance enhancements to avoid wasted array copying.