Miscellaneous warning and bug fixes caught by stricter checking.