free allocated objects properly