Porting over some fixes and formatting changes