code cleanup and back porting