More work on writer, outputadapters, their relation and linking. Also cleaning code