Fix build and some warnings