Optimized the UBM trainer