Minor refactoring
Refactoring and documenting