better dLocation math

More pull requests, hooray! See commit(s) for details.