Use mutating appends on unique vectors.
Use mutating sets on unique vectors.
Inline simple functions.
Use unions instead of casts. Remove 'junk'.