Generating entities, fixed possible heap corruption