Clean up function generation based on unit type vector