Fixed sqlite related memory leaks.
Merge branch 'issue-15' into develop
Fixes issue-17
Merge branch 'issue-17' into develop