Fix automatic setting of initial state when states array is empty.