Refactoring

Updated documentation and comments