Fix first sample and get rid of memory leaks.
Fix tests.
Merge branch 'develop'