Made a bunch of changes to fix the distance bearing plugin, and to make it more generic