Optimize creation of boxed primitives
Merge pull request #2826 from federicobond/primitive-optimization

Optimize creation of boxed primitives