Fix more undefined values (applicable only to master). Add new debug build type
to find this class of bugs with gcc/clang. Closes ticket:4216