[refactor] refactor and fix bugs
Merge branch 'refactor' into dev