Fixes for upstream merge