fixed free() problems