Fix problem, lower memory usage in model_and_analyze script