Fix bugs when pip has not been installed + refactoring