Modify data structures to accept custom free function.