factor out setup code
Merge pull request #890 from goodfeli/warm_start

factor out setup code