Factored out rendering logic along with slimming down functionality