Added support for memory leak detection.

Fixed a memory leak.
Next adding encryption