fix some compile errors and warnings