Fix more compile warnings and a minor bug