Fixed problems with dodgy C++ casts, see https://trac.openstreetmap.org/ticket/3299