(Imported from upstream's 519ad9b3845c475d29db8b84b59bde7edecb4e70.)
This change fixes a number of build warnings.
Initial fork from f2d678e6e89b6508147086610e985d4e8416e867 (1.0.2 beta). (This change contains substantial changes from the original and effectively starts a new history.)