Added stack, and refactored.