Stated folder check functions and some refactoring