Improve the performance

Speed up the program when -h/-v is specified.