Porting some old code to UI library.