fix compile error (and fix most of the warnings)