fix #595 and fix #550

@antgonza and I chatted about this. For sample template it is `<study_id>_<timestamp>`, for prep template is `<study_id>_prep_<prep_id>_<timestamp>` (see line 1302). I agree with this format. So, @adamrp; if you also agree, feel free to merge the PR.