Added documentation
Applied minor refactoring