Factored the stack into a separate class.