Optimize UI and viewport drawing