Broke out the code into encapsulated classes.