Improved pretty-print function