Formatted code so easier to read in places.