fix errors and warnings for GCC 4.6