Fix build and fix warnings