Some refactoring and add zsh completion