Refactor PersistentStack

Fixes #10