porting to ARM and cleanup