Start refactoring for more general purpose use