Change devices arrays from 1-origin to 0-origin.