fix and implement distance selector, minor bug fixes
merge commit, still don't know if this is right