Fix 'd' calculation #137