Modified LKM code, added deriv control