added clean_trail option for generating documents