Prevent useless svg tag for empty text
Added grouping by layer (z-indexing) + Tidying