Autodetecting type of state arrays and handling appropriately