Working DynamicStack implementation.