Fix a build error and various warnings