Adding Kadanes and modifying some code