Fixed some leaks. Memory in using about 1Gb.

Fixed somo leaks. Memory in using is about 1Gb.