Printing functionality, more refactoring