Fix compile errors and warnings.