Modularized the code some more by moving...

...some of the subroutines into separate classes.