Moved code into classes.