Moved code into helper classes.