Externalized the code to make figures 2 through 4.