Refactored everything into proper classes.