xlength now variable in x, y, z directions.
Replaced direct computations of index by call to idx() function.
lengths for x,y,z directions now read in from file.