Fix some assorted compile warnings

Just ran through the warnings generated at compile time and fixed those which seemed reasonable.  A couple of these (57a142b, 6ac4fcd) were indicative of actual bugs.