Fix device list index calculation, needs std::distance, duh.