Refactors Stack and stack_spec