fix potential memory leak and delete/delete[] mismatch
Merge pull request #30 from jmakovicka/memleak-fix

fix potential memory leak and delete/delete[] mismatch