Refactor and Update documentation