Some functions did more than one thing, this should be reviewed to see if we can adhere more to the single responsibility principle.