Tidying up code, making things more cohesive