Code Refactor and Documentation