Pretty print fixes

Fixes #1998.