Refactor and adding some more docs.