Some documentation started as long with some code refactoring