add version command, and some refactoring.