Refactored and updated documentation