Correct memory management implemented.