Cleaning up the code to get a smmaller diff.