Code cleaning and optimization in UI