improvements/fixes to estimate derivative