Fix warnings and compilation errors with gcc 4.8