Quite a big refactor of the CLI class to make it slightly more manageable