BAT plugin - code optimization