Output phase problem

This pull request depends on pull request 132, so it might be better to merge that one first.