Dirstack implementation that works.