Modify some rendering code to account for undefined/empty values

The code is messy again :(
More modifications

Let's hope we have a good structure this time...

It is really, awfully complicated.
More code, always disorganized

Very hard to do TDD with such an awfully complex algorithm...