Changed PDCube so that it is previous, next, intermediate instead of previous, intermediate, next to reduce the number of array accesses in location choice and to make it row wise for better cpu performance.