Adds pruning and frozen key support

related to #414 

Needs more tests, but here for comments / review.