These project shows how I solved many of this issues, but you’ll need to adapt the parts you like to your game:
RTS Unit Management Example