Fixing memory leaks and some cosmetics
Merge pull request #9 from mvala/master

Fixing memory leaks and some cosmetics