Working persistent queue

TODO: add more comments and implement TODOs