Sorted Index of x values.

X values need to be sorted to correctly calculate the distance between
consecutive peaks.
Fixed heart rate counting.

Heart rate counting now works perfectly, provided the video is stable
enough.
Also cleared up some variable names.
Cleared variable names and comments