Code refactor & documentation improvement