Reorganize and fix pretty print