Refactoring console code.