Move core code into a class