Started documentation and refactor