Algorithms and Complexity of Difference Logic