Merged in some minor fixes from porting