Porting back some fixes