Improved stream type logic in StreamAndFileHandler.