implemented prune
finished with flags. bugs likely