Smarten the doRedraw function

The doRedraw function now add the missing layers and delete the useless ones.
It is way quicker than calling doRender.