Derivatives with some clean up
Remove unnecessary code.