updated min stack, fixed bugs.