Modularized scripts to make them easier to read and work with

At least I think it's easier to follow along and add to. This commit is also
made so we can get people to review it.