Code cleanup:
  - clean up unused import and commented off codes
  - rename unaccurate naming
  - reorganize some function calling logic