Cleaning up code for analysing