Refactor printing

I hope I can simplify it more.