Update for upstream changes. Most tests passing.