move stack into base class
@schneem's refactoring