Release 4.0

Merge final release 4.0 into master.