Fix printing issues (fixes #39)