Add callbacks for freeing up memory