Fixing output as well.

Same fixes that were done for the input.