Render refactor (with couple of fixes)

For loops or if checks in inlined functions are usually not good practice, what's the reasoning behind making this inline?