Do some refactor & update the doc