Fixed broken pipe
refactoring
refactoring
documenting
improved code quality
minor fixes