Sync with upstream.
Fix some compiler warnings.
Work around rust issue #13246.
Error handling!