Merge changes from mainline upto r685.
This branch is now fully merged. Any remaining problems in doxygen, scripts and tsuite should now be resolved.