Added protection to input/output streams so that exceptions in serializers don't corrupt said streams.