Switch to GCC 4.7 and fix compile errors