Fixed issues for upstream merge.