improving code, freeing memory, deleting objs

making exit better