Refactored to enable plugging-in custom destination file producer.
Added missing licence info.