code cleanup to remove vast majority of gcc -Wall warnings