Printing improvements and refactorings