Sorted out some output error handling issues