Refractored UI code.