GCC inspired type fixes plus one coverity inspired fix
Merge pull request #212 from ged-lab/moar-type-fixes

GCC inspired type fixes plus one coverity inspired fix