Fix build warnings and miscellaneous issues.