Fix some porting mistakes