change threshold
add debug output
changed keyframe distance function