removed invalid frees in main