Transformer optimization