Fixed up code somewhat to remove compile warnings.