WIP: Refactor codes, DB connection