TS-1785 Fixes to make it build with gcc-4.8, but still needs TS-1787 as well
Added TS-1787 (cloned as TS-1904), which needs to be backported to compile
with latest gcc-4.8.