Optimization pass #2: replace all usage of 'createUnit' with 'createUnit array'