memory improvements
Merge pull request #1 from vgupta1/master

Preallocate output of 'sample!'