Merged in version 4.0.2 and other upstream changes.