Some refeactoring.