Cleanly separate rendering and event handling