Moved some code to the cli module.