fix compile errors and warnings