big fix and refactoring about #1

1. fix some memory issues
2. use getopt to parse parameters
3. new option: -i <indexes>, use dictionary indexes delimited with commas to specify dictionary
4. polish output format