Tidy up function definitions