Remove unused code and add functionality

1. remove unused code
2. ctrl+c handler
3. some bugs fixed
4. add dir-only option