Fixed Resource Leaks

Signed-off-by: Santhosh Edukulla <santhosh.edukulla@gmail.com>