Rework texture generating code, add texture grouping

<b>paren</b>theses <b>bal</b>ance