restructuring and optimizations

- moved misc and pkg to data/scripts
- started recover procedure
- optimized clean stale ids