minor changes; save model and write output after each iter (when dev is provided)