Extract sampling code to method
Add memoizations and 'of' methods