fix compilation and a bunch of warnings