Fixed an issue with free'ing memory twice