Improved text output and smaller refactoring