Refactorization and .git dir checking.