Add errors to error log, free resources
Add sample, work on freeing memory
Improve sample