Improved output handling