Refactor and homemade docstrings