Selectunits rewrite

I think you were working with the SelectUnits script, so we should probably merge your updates before this so I can make sure they get integrated properly.