Fixed a bug where the program was freeing memory it didn't own