Factor code to mkgit and lazy_extract