Some refactoring and development for sudo