Render refactor (with couple of fixes)

i haven't tested it much