major changes to code that automate parameter changes, and more neatly package stuff in functions