fix some porting errors