Replace class definitions with generator funcs
Refactor stack pops