Memory leaks fixed

Signed-off-by: Rostislav Khlebnikov <r.khlebnikov@gmail.com>