Added stack with dynamic memory management