Pulled in some old code, but not yet ported to the new api.