Changes made to correct memory leaks