store units in list instead of array
use .Length instead of 'n' variables
make PlayerVisRemoveEvt.tiles an array instead of a list
declare more local variables inline instead of at top of function