Render code cleanup, simplified main()