Fix compile warnings & errors with gcc