renderer: clean up, var scope, formattings, code style